#include<iostream>

using namespace std;

int findMinNumInRotateArr(int * nums, int length ){
    int left = 0;
        int right = length-1;
        while (left < right){
            int mid = left + (right - left)/2;
            if (nums[mid] > nums[right]){
                // mid大于right值，将mid赋值给left缩小查找范围[mid+1, right]
                left = mid + 1;
            }else if (nums[mid] < nums[right]){
                // mid小于right,　将mid赋值给right缩小查找范围[left, mid]
                right = mid;
            }else {
                // mid == right, right--，　因为mid是与right比较的，所以应该right--,而不应该left++;
                right = right - 1;
            }
        }
        return nums[left];
}

int main(void){
    int arr[] = {2,2,2,2,0,2};
    int length = 6;
    cout << findMinNumInRotateArr(arr, length) << endl;
    return 0;
}